package com.lindroy.androidplayer.ui.home

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.lindroy.androidplayer.logic.Repository
import com.lindroy.androidplayer.logic.model.ArticleResp
import com.lindroy.androidplayer.logic.model.BannerResp

/**
 * @author Lin
 * @date 2021/4/8
 * @function 首页数据，包含文章列表和置顶文章
 */
@Deprecated("之前的网络请求框架代码，已废弃")
class HomePageViewModel : ViewModel() {

    val bannerList = ArrayList<BannerResp>()

    private val articles = MutableLiveData<Int>()

    val articleList = ArrayList<ArticleResp>()

    val articleLiveData = Transformations.switchMap(articles) {
        Repository.getArticlesList(it)
    }

    fun getArticleList(page: Int) {
        articles.value = page
    }

    fun getBanners() = Repository.getBanners()

}